/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package m12cqis01.nhathv.util;

import java.util.Calendar;

/**
 *
 * @author Vu Nhat
 */
public class DateTimeMaster {

    Calendar now = Calendar.getInstance();

    public DateTimeMaster() {
    }

    public int getHourOfDay() {
        int s = now.get(Calendar.HOUR_OF_DAY);
        return s;
    }

    public int getSecond() {
        int s = now.get(Calendar.SECOND);
        return s;
    }

    public int getMinute() {
        int s = now.get(Calendar.MINUTE);
        return s;
    }

    public int getYear() {
        int s = now.get(Calendar.YEAR);
        return s;
    }

    /*
     * Tháng Julian được tính từ 0
     */
    public int getMonth() {
        int s = now.get(Calendar.MONTH) + 1;
        return s;
    }

    public int getDay() {
        int s = now.get(Calendar.DAY_OF_MONTH);
        return s;
    }

    public int getMilisecond() {
        int s = now.get(Calendar.MILLISECOND);
        return s;
    }

    public String calculateSecond(int minute, int second, int milisec) {
        return "" + (minute * 60 + second + "." + milisec);
    }

//    public String getNowTime(){
//        return now.
//    }

    public static void main(String[] args) {
        DateTimeMaster timer = new DateTimeMaster();
        float time;
        int h;
        int m;
        int s;
        int ml;
        h = timer.getHourOfDay();
        m = timer.getMinute();
        s = timer.getSecond();
        ml = timer.getMilisecond();
        System.out.println(h + ":" + m + ":" + s + ":" + ml);
        time = Float.parseFloat(timer.calculateSecond(m, s, ml));
        System.out.println(time);
        System.out.println(time+100);
    }
}
